package org.springframework.security.authorization;

/**
 * @author Dillon
 * @date 2024/6/28
 * @slogan 致敬大师 致敬未来的你
 * @desc 权限校验接口，标记是否有权限访问
 */
public class AuthorizationDecision implements AuthorizationResult {

	/**
	 * 存储是否有权限访问资源
	 */
	private final boolean granted;

	/**
	 * 构造函数， 初始化是否有权限访问资源
	 *
	 * @param granted 是否有权限访问资源
	 */
	public AuthorizationDecision(boolean granted) {
		this.granted = granted;
	}

	/**
	 * 获取是否有权限访问资源表示
	 *
	 * @return 权限访问资源标识
	 */
	@Override
	public boolean isGranted() {
		return this.granted;
	}

	/**
	 * 复写ToString
	 *
	 * @return toString
	 */
	@Override
	public String toString() {
		return getClass().getSimpleName() + " [granted=" + this.granted + "]";
	}

}
